<!DOCTYPE HTML>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <script src="../../static/js/jquery-3.5.1.min.js" th:src="@{/js/jquery-3.5.1.min.js}"></script>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui/css/H-ui.min.css" th:href="@{/h-ui/css/H-ui.min.css}"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/H-ui.admin.css" th:href="@{/h-ui.admin/css/H-ui.admin.css}"/>
    <link rel="stylesheet" type="text/css" href="../../static/lib/Hui-iconfont/1.0.8/iconfont.css" th:href="@{/lib/Hui-iconfont/1.0.8/iconfont.css}"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/skin/default/skin.css" id="skin" th:href="@{/h-ui.admin/skin/default/skin.css}"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/style.css" th:href="@{/h-ui.admin/css/style.css}"/>
    <link rel="stylesheet" href="../../static/Semantic-UI-master/dist/semantic.min.css" th:href="@{/Semantic-UI-master/dist/semantic.min.css}">
    <link rel="stylesheet" href="../../static/css/custom.css" th:href="@{/css/custom.css}">

    <title>用户评论</title>
</head>
<script type="text/javascript" th:inline="javascript">
    $(function () {
        if(![[${session.admin}]]){
            alert("请先去登录")
            window.location.replace("/sy/syadmin/admin")
        }
    })

</script>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 评论管理 <span class="c-gray en">&gt;</span> 评论列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c m-padded-t-middle">
        <div class="" style="padding-bottom: 10px">
            <input class="searchinput1 prompt" type="text" id="searchinput" placeholder="搜索评论......">
            <button class="searchbutton1 ui teal button" id="searchbutton"><i class="search icon"></i></button>
        </div>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="r">共有数据：<strong id="datanum" th:text="${session.commentadminList.size()}">88</strong> 条</span> </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="60">ID</th>
                <th width="60">用户ID</th>
                <th width="100">头像</th>
                <th width="60">用户名</th>
                <th width="60">课程ID</th>
                <th>评论内容</th>
                <th width="40">父节点</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody id="searchshow">
            <tr class="text-c" th:each="comment:${session.commentadminList}">
                <td th:text="${comment.commentId}">1</td>
                <td th:text="${comment.userId}">1</td>
                <td><img th:src="${comment.userImg}" src="https://edu-linagyu-sy.oss-cn-shenzhen.aliyuncs.com/Imges/0f6a15acf0864b80b44bdcd87e52d07esx.jpg" style="width: 60px;height: auto;"></td>
                <td th:text="${comment.userName}">sytest</td>
                <td th:text="${comment.courseId}">1</td>
                <td th:text="${comment.commentP}">这个terr命令安装不了</td>
                <td th:text="${comment.father}">0</td>
                <td class="td-manage">
                    <a title="删除" href="javascript:;" th:onclick="comment_del(this,[[${comment.commentId}]])" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
            </tr>

            </tbody>
        </table>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->

<script type="text/javascript" src="../../static/lib/layer/2.4/layer.js" th:src="@{/lib/layer/2.4/layer.js}"></script>
<script type="text/javascript" src="../../static/h-ui/js/H-ui.min.js" th:src="@{/h-ui/js/H-ui.min.js}"></script>
<script type="text/javascript" src="../../static/h-ui.admin/js/H-ui.admin.js" th:src="@{/h-ui.admin/js/H-ui.admin.js}"></script> <!--/_footer 作为公共模版分离出去-->
<script src="../../static/js/jquery-ui.min.js" th:src="@{/js/jquery-ui.min.js}"></script>
<script src="../../static/Semantic-UI-master/dist/semantic.min.js" th:src="@{/Semantic-UI-master/dist/semantic.min.js}"></script>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js" th:src="@{lib/My97DatePicker/4.8/WdatePicker.js}"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js" th:src="@{lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js" th:src="@{lib/laypage/1.2/laypage.js}"></script>
<script type="text/javascript">
    /*评论-删除*/
    function comment_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '/sy/comment/deletecomment',
                cache: false,
                data: {'commentId':id},
                success: function(data){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                },
                error:function(data) {
                    layer.msg('出错了',{icon:0,time:1000});
                },
            });
        });
    }

    //搜索
    $("#searchbutton").click(function () {
        var text = $("#searchinput").val();
        $.ajax({
            type: "get",
            cache: false,
            url: "/sy/comment/search",
            data: {"searchstr":text},
            contenType: "application/json;charset=utf-8",
            success: function (data) {

                if(data.length==0){
                    layer.msg('没有搜索到内容',{icon:0,time:2000});
                }else {
                    $("#datanum").text(data.length);
                    var htmls = '';

                    for(let i=0; i<data.length; i++){
                        var add ='<tr class="text-c">\n' +
                            '    <td>'+data[i].commentId+'</td>\n' +
                            '    <td>'+data[i].userId+'</td>\n' +
                            '    <td><img src="'+data[i].userImg+'" style="width: 60px;height: auto;"></td>\n' +
                            '    <td>'+data[i].userName+'</td>\n' +
                            '    <td>'+data[i].courseId+'</td>\n' +
                            '    <td>'+data[i].commentP+'</td>\n' +
                            '    <td>'+data[i].father+'</td>\n' +
                            '    <td class="td-manage">' +
                            '<a title="删除" href="javascript:;" onclick="comment_del(this,'+data[i].commentId+')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>\n' +
                            '</tr>';


                        htmls += add;
                    }
                    $("#searchshow").html(htmls);
                }
            },
            error: function (message) {
                layer.msg('出错了',{icon:0,time:1000});
            }
        })

    })
</script>
</body>
</html>